package hdoj;


import java.util.Arrays;
import java.util.Scanner;

public class MazeHDU1312 {

	private static final int[][] dir = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};
	
	private static final char START = '@';
	private static final char OBSTACLE = '#';
	
	private static final int MAX = 22;
	
	private int length = 0;
	
	private int rows, columns;
	
	private char[][] maze = new char[MAX][MAX];
	
	private boolean[][] visited = new boolean[MAX][MAX];
	
	public static void main(String[] args) {
		MazeHDU1312 object = new MazeHDU1312();
		object.getRes();
	}
	
	public void getRes(){
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()){
			columns = scanner.nextInt();
			rows = scanner.nextInt();
			if(columns == 0 && rows == 0){
				break;
			}
			length = 0;
			int startX = 0, startY = 0;
			for(int i = 0; i < rows; i++){
				String str = scanner.next();
				for(int j = 0; j < columns; j++){
					if(str.charAt(j) == START){
						startX = i;
						startY = j;
					}
					maze[i][j] = str.charAt(j);
				}
				Arrays.fill(visited[i], false);
			}
			visited[startX][startY] = true;
			length = dfs(startX, startY, 0);
			System.out.println(length);
		}
		scanner.close();
	}
	
	//Runtime 249MS
	public int dfs(int x, int y, int length){
		int res = 1;
		for(int i = 0; i < dir.length; i++){
			int curX = x + dir[i][0];
			int curY = y + dir[i][1];
			if(curX < 0 || curX >= rows || curY < 0 || curY >= columns || maze[curX][curY] == OBSTACLE ||
					visited[curX][curY]){
				continue;
			}
			visited[curX][curY] = true;
			res += dfs(curX, curY, length + 1);
		}
		return res;
	}
}
